package org.example.task.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.example.task.model.dto.PageDTO;
import org.example.task.model.po.Permission;
import org.example.task.mapper.PermissionMapper;
import org.example.task.model.query.PermissionPageQuery;
import org.example.task.model.vo.permission.PermissionVO;
import org.example.task.service.IPermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-06-30
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements IPermissionService {

    @Override
    public PageDTO<PermissionVO> getPermissionPage(PermissionPageQuery permissionPageQuery) {
        Page<Permission> permissionPage = permissionPageQuery.toPage();
        lambdaQuery().like(permissionPageQuery.getPermissionName() != null, Permission::getPermissionName, "%" + permissionPageQuery.getPermissionName() + "%")
                .page(permissionPage);
        return PageDTO.of(permissionPage, PermissionVO.class);
    }
}
